package com.qqtech.qquan.user.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.qqtech.core.common.util.BeanUtil;
import com.qqtech.core.frame.dao.BaseDaoImpl;
import com.qqtech.qquan.user.model.UserDraw;
import com.qqtech.qquan.user.model.UserDrawQuery;
import com.qqtech.qquan.user.model.UserDrawVo;

@Repository
public class UserDrawDaoImpl extends BaseDaoImpl<UserDraw> implements UserDrawDao {
	public static final Logger log = LoggerFactory.getLogger(UserDrawDaoImpl.class);

	@Override
	public int queryCountAdmin(UserDrawQuery query) {
		return sqlSessionTemplate.selectOne(getSqlName("selectCountAdmin"), BeanUtil.toMap(query));
	}

	@Override
	public Page<UserDrawVo> queryPageListAdmin(UserDrawQuery query, Pageable pageable) {
		List<UserDrawVo> contentList = sqlSessionTemplate.selectList(getSqlName("selectAdmin"),
				getParams(query, pageable));
		return new PageImpl<UserDrawVo>(contentList, pageable, this.queryCountAdmin(query));

	}

	@Override
	public List<UserDrawVo> queryList4Draw(UserDrawQuery userDrawQuery, Pageable pageable) {
		return sqlSessionTemplate.selectList(getSqlName("select4Draw"), getParams(userDrawQuery, pageable));
	}

}
